package com.haozi.ehub.core.dynamic;

import com.haozi.ehub.core.enums.DatabaseEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

/**
 * @author ：terry
 * @date ：Created in 2020/6/5 14:25
 * @description：TODO
 * @version: 1.0
 */
@Deprecated
public class DynamicDatabase extends AbstractRoutingDataSource {
    private static final Logger LOGGER =
            LoggerFactory.getLogger(DynamicDatabase.class);

    @Override
    protected Object determineCurrentLookupKey() {
        DatabaseEnum database = DynamicDatabaseContextHolder.getDatabase();
        if(database != null){
            return database;
        }else{
            return DatabaseEnum.SLAVE_1.getValue();
        }
    }
}
